package cn.wolfcode.p2p.call.util;

import cn.wolfcode.p2p.config.HostingConfig;
import cn.wolfcode.p2p.util.UserContext;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 托管工具类
 */
public class Hosting {

    /**
     * 封装参数
     */
    public static Map hostingBaseParams(HostingConfig hostingConfig) {
        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("version", hostingConfig.getVersion());
        paramsMap.put("request_time", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
        paramsMap.put("partner_id", hostingConfig.getPartnerId());
        paramsMap.put("_input_charset", hostingConfig.getInputCharset());
        paramsMap.put("sign_type", hostingConfig.getSignType());
        paramsMap.put("sign_version", hostingConfig.getSignVersion());
        paramsMap.put("encrypt_version", hostingConfig.getEncryptVersion());
        return paramsMap;
    }

    /**
     * 封装业务参数
     */
    public static Map<String,Object> hostingServiceParams(Map map,String username){
        map.put("service","create_activate_member");
        map.put("identity_id","wolf_"+username);
        map.put("identity_type","UID");
        map.put("member_type","1");
        map.put("client_ip", UserContext.getIp());
        return map;
    }
}